<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>buildRecord</title>
    <link rel="stylesheet" type="text/css" media="all" href="/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" media="all" href="/css/common.css"/>
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/myJs.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="/css/CaseManager.css"/>
</head>
<body>
<div class="layui-fluid">
    <div class="row">
        <div class="layui-col-sm12">
            <div style="width: 160px; font-weight: bolder; font-size: large; margin-top: 20px; margin-left: auto; margin-right: auto">服务构建申请列表</div><br/>
            <button class="layui-btn layui-btn-primary layui-col-md-offset11" style="width: 100px" onclick="shua()">刷新</button>
        <table class="layui-table" id="buildAuditTable" lay-filter="table"></table>
            <button class="layui-btn layui-btn-normal layui-col-md-offset11" style="width: 130px" onclick="buildApply()">查看构建情况</button>
            <button class="layui-btn layui-btn-warm layui-col-md-offset10" style="width: 130px" onclick="buildRecord()">查看构建记录</button>

            <!--<a href="/server/baseServer" style="margin-top:10px;" target="_blank" class="layui-btn">点击返回</a>-->
            <!--<input class="layui-btn" type="button" value="点击返回" onclick="backRecord()"/>-->
        </div>
    </div>
</div>
<div class="fly-footer">
    <p><a target="_blank">我打 - 服务管理系统</a> 2018</p>
</div>
<script>
    function shua() {
        loadPage("/server/buildAuditList");
    }
    function buildRecord() {
        loadPageWithBlank("/server/buildRecord")
    }
    function buildApply() {
        loadPageWithBlank("http://192.168.200.222:8888/")
    }
    function loadPage(url) {
        window.location.href = url;
    }
    function backRecord(){
        loadPage("/server/buildRecord")
    }
    layui.use('form', function(){
        var form = layui.form;
        form.render();
    });
    layui.use('table', function() {
        var table = layui.table, $ = layui.jquery;
        table.render({
            elem: '#buildAuditTable'
            , url: '/server/getbuildRecordForPaging'
            , cellMinWidth: 80
            , page: true
            , cols: [[
                //{field: 'buildId', title: 'ID', align: 'center', width: 60}
                {field: 'vServerName', title: '服务名', align: 'center', width: 160}
                ,{field: 'serverType', title: '服务类型', align: 'center', width: 160}
                , {field: 'vBranch', title: '前端分支', align: 'center', minWidth: 100}
                , {field: 'vDev', title: '构建环境', align: 'center', minWidth: 100}
                , {field: 'vLeader', title: '负责人', align: 'center', width: 150}
                , {field: 'vVersion', title: '版本号', align: 'center', width: 150}
                , {field: 'dtCreateTime', title: '申请时间', align: 'center', minWidth: 160}
                , {fixed: 'right', width: 350, align: 'center', toolbar: '#EditBaseServer'}
            ]],
            where: {
                vServerName: '',
                vLeader: '',
                eAudit: '1'
            },
            request: {
                pageName: 'pageNumber',
                limitName: 'pageSize'
            },
            response: {
                countName: 'total',
                dataName: 'rows'
            }
        });
        table.on('tool(table)', function (obj) {
            var data = obj.data;
            if (obj.event === 'audit') {
                layer.confirm('开始构建吗', function (index) {
                    $.ajax({
                        url: "/server/buildAudit?buildId=" + data.buildId,
                        success: function (data) {
                            if (data == "true") {
                                layer.alert("成功!")
                            } else {
                                layer.alert("失败了!")
                            }
                        }
                    })
                });
            }

        });
    });
</script>
<script type="text/html" id="EditBaseServer">
    <a class="layui-btn layui-btn-xs" lay-event="audit">开始构建</a>

</script>

</body>
</html>